package com.darrenchan.leetcode;

/**
 * @Desc
 * @Author chenchi03
 * @CreateTime 2020-01-11 16:38
 */
public class Q518 {
    public int change(int amount, int[] coins) {
        if (amount == 0) {
            return 1;
        }

        int[] dp = new int[amount + 1];
        dp[0] = 1;
        for (int i = 1; i < dp.length; i++) {
            int res = 0;
            for (int j = 0; j < coins.length; j++) {
                if (i - coins[j] >= 0) {
                    res += dp[i - coins[j]];
                }
            }
            dp[i] = res;
        }

        return dp[amount];
    }
}
